<template>
<div class="oo">
  <el-form ref="form" :model="form" label-width="80px">
    <el-form-item label="账号">
      <el-input style="width: 400px" v-model="form.account" placeholder="账号"></el-input>
    </el-form-item>
    <el-form-item label="密码">
      <el-input style="width: 400px" placeholder="密码" v-model="form.secret"></el-input>
    </el-form-item>
    <el-row class="bn">
      <el-button type="info" plain @click="login_get_token">登录</el-button>
    </el-row>
  </el-form>
</div>
</template>

<script>
    export default {
        name: "Login",
      data() {
        return {
          //this.setUrl('http://101.43.63.72')
          http:this.config.ip,
          token:"",
          form: {
            account: '',
            secret: '',
            type:100
          }
        }
      },
      methods: {
        login_get_token() {
          this.$xin.post(this.http+"/v1/token", this.form).then(res=>{
            this.token=res.data.token;
            //设置到localStorage，然后直接读

            localStorage.setItem('token', this.token);
            console.log(localStorage.getItem('token'));
            //token失效后跳到登录完成后应该要跳回之前那个页面
            window.location.href='/#/case';

          })
        }
      }
    }
</script>

<style scoped>
.oo{
  margin-top: 300px;
  margin-left: 500px;
}
  .bn{
    margin-left: 220px;
  }
</style>
